#include<iostream>
using namespace std;

int func(int n){
    int count=0;
    for(int i=0;i<n;i++){
        count = count*10+2;
    }
    return count;
}

int main(){
    int n;
    cout<<"请输入n的大小:"<<endl;
    cin>>n;
    int count=0;
    for(int i=1;i<=n;i++){
        count = count+func(i);
    }
    cout<<"结果为: "<<count<<endl;
    return 0;
}
$
